package com.gudong.model.result;

import lombok.Data;

@Data
public class AppResult<T> {
    private String code;
    private String msg;
    private T data;


    private AppResult() {

    }

    public static <T> AppResult<T> success(T data) {
        AppResult<T> result = new AppResult<T>();
        result.setCode("200");
        result.setMsg("success");
        result.setData(data);
        return result;
    }

    public static <T> AppResult<T> success() {
        AppResult<T> result = new AppResult<T>();
        result.setCode("200");
        result.setMsg("success");
        return result;
    }

    public static <T> AppResult<T> error(String code, String msg) {
        AppResult<T> result = new AppResult<T>();
        result.setCode(code);
        result.setMsg(msg);
        return result;
    }

    public static <T> AppResult<T> error(String msg) {
        AppResult<T> result = new AppResult<T>();
        result.setCode("500");
        result.setMsg(msg);
        return result;
    }
}
